package drds.binlog.event.mariadb;

import drds.binlog.LogByteBlock;
import drds.binlog.event.FormatDescriptionLogEvent;
import drds.binlog.event.IgnorableLogEvent;
import drds.binlog.event.LogHeader;

/**
 * mariadb的ANNOTATE_ROWS_EVENT类型
 */
public class AnnotateRowsEvent extends IgnorableLogEvent
{

    private String rowsQuery;

    public AnnotateRowsEvent(LogHeader logHeader, LogByteBlock logByteBlock, FormatDescriptionLogEvent formatDescriptionLogEvent)
    {
        super(logHeader, logByteBlock, formatDescriptionLogEvent);

        final int commonHeaderLength = formatDescriptionLogEvent.getCommonHeaderLength();
        final int postHeaderLength = formatDescriptionLogEvent.getPostHeaderLengths()[logHeader.getType() - 1];

        int offset = commonHeaderLength + postHeaderLength;
        int len = logByteBlock.limit() - offset;
        rowsQuery = logByteBlock.getFullString(offset, len, LogByteBlock.ISO_8859_1);
    }

    public String getRowsQuery()
    {
        return rowsQuery;
    }

}
